<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        function getMessage() {
            // 实例化一个xmlHttpRequest对象
            var req = new XMLHttpRequest();
            // 设置xmlHttpRequest对象的回调函数
            req.onreadystatechange = function () {
                if (req.readyState == 4 && req.status == 200) {
                    // 接收响应结果,处理结果
                    alert("第六章")

                    document.getElementById("message").value = req.responseText;
                }
            }
            // 设置发送请求的方式和请求的资源路径
            req.open("GET", "/hello?username=zhangsan");
            // 发送请求
            req.send();
        }
    </script>
</head>
<body>
<button onclick="getMessage()">按钮</button>
<input id="message" type="text">
</body>
</html>